import { toData, toDataForSys } from "@/appBase/utils";
import { http, httpDel, httpGet, httpPost } from '@/appBase/request';

/**
 * 登录
 * @param {Object} parmas
 * @param {String} parmas.code 
 * @param {String} parmas.password 
 * @param {String} parmas.username 
 * @param {String} parmas.uuid 
 */
export function login(parmas) {
    return Promise.resolve({
        "msg": "操作成功",
        "code": 200,
        "token": "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjVhMDljMjE0OGM2YTQ3ZjlhZWE5MmM4YjYzNWZjZTMwIn0.xPTEhHChrwHlW7nzAGbJhTW6dpG19VVcbB2oFf4mj71MKBi2zNmBZcHsoKByZUNmF0rjVXAFcB1yyLOYu6ddug",
        "message": "操作成功"
    })
    // return httpPost('/login',parmas).then((result) => toDataForSys(result));
}

export function getInfo() {
    const result = {"msg":"操作成功","code":200,"permissions":["*:*:*"],"roles":["admin"],"user":{"searchValue":null,"createBy":"admin","createTime":"2022-01-23 22:31:56","updateBy":null,"updateTime":null,"remark":"管理员","params":{},"userId":"1","deptId":"102","userName":"admin","nickName":"admin","email":"","phonenumber":"","sex":"0","avatar":"","salt":null,"status":"0","delFlag":"0","loginIp":"106.89.37.70","loginDate":"2023-02-22 17:54:21","dept":{"searchValue":null,"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"params":{},"deptId":"102","parentId":"100","ancestors":null,"deptName":"总工办","orderNum":"2","leader":"","phone":null,"email":null,"status":"0","delFlag":null,"parentName":null,"deptLeaderId":null,"firstDeptId":null,"areaName":null,"children":[]},"roles":[{"searchValue":null,"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"params":{},"roleId":"2","roleName":"职员","roleKey":"R-Common","roleSort":"2","dataScope":"4","menuCheckStrictly":false,"deptCheckStrictly":false,"status":"0","delFlag":null,"flag":false,"menuIds":null,"deptIds":null,"admin":false}],"roleIds":null,"postIds":null,"roleId":null,"directLeaderId":"0","admin":true}}
    // return httpGet('/getInfo').then((result) =>  toDataForSys(result));
    return Promise.resolve(toDataForSys(result));
}

export function postLogout() {
    return httpDel('/logout').then((result) => toDataForSys(result));
}

// 获取验证码
export function getCodeImg() {
    return httpGet('/captchaImage').then((result) => toDataForSys(result));
}
